<template>
  <div class="user-menu">
    <div class="user-box">
      <UserInfoD v-if="useUser.token !== ''"></UserInfoD>
      <div class="not-log" v-else-if="useUser.token === ''">
        <span>请登录/注册</span>
        <div class="log-btn">
          <el-button type="primary" round size="large" @click="toLoginView">登录 | 注册</el-button>
        </div>
      </div>
    </div>
    <div class="button-list">
      <el-button type="primary">发布项目</el-button>
      <el-button type="primary" plain>发布需求</el-button>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref, reactive, toRefs } from "vue"
import { useRouter, useRoute } from 'vue-router'
import UserInfoD from '@/components/UserInfoDetail/index.vue'
import { useUserStore } from '@/store/user'

const useUser = useUserStore();
const router = useRouter();
const route = useRoute();

// 跳转登录页面方法
const toLoginView = () => {
  console.log('跳转到login')
  router.push({
    name: 'Login',
  })
}
</script>

<style lang="less" scoped>
@border-color: #dcdfe6;

.user-menu {
  border: 1px solid @border-color;
  border-radius: 10px;
  box-shadow: 0 10px 10px 5px rgba(0, 0, 0, .1);

  :deep(.user_info) {
    border: 1px solid @border-color;
    box-shadow: none;
  }

  .not-log {
    padding: 10px 0 20px 0;
    height: 100px;
    border-bottom: 2px solid @border-color;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    
    span {
      padding: 20px 0;
      font-size: 20px;
      font-weight: 700;
    }
  }

  .button-list {
    height: 175px;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    :deep(.el-button + .el-button) {
      margin-left: 0;
      margin-top: 20px;
    }
  }
}
</style>